/**
 *     This file is part of cesm-ws.
 *
 *     cesm-ws, Web Service for Community Earth System Model
 *
 *     Copyright (c) 2010, Purdue University and/or affilicates or thrid-party contributors as
 *     indicated by the @author tags or express copyright attribution statements
 *     applied by the authors. All third-party contributions are distributed under
 *     license by Purdue University.
 *
 *     cesm-ws is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this distribution.  If not, see <http://www.gnu.org/licenses/>.
 */

package edu.purdue.rcac.cesm.define;

/**
 * This is enumeration of valid values for createCase input field 'machine'.
 * This class is written in accordance with 'create_newcase -list' output for
 * CCSM 4.0 scripts.
 * 
 * @author Han Zhang
 * 
 */
public enum Machine {
	/**
	 * NCAR IBM p6, os is AIX, 32 pes/node, batch system is LS
	 */
	bluefire,

	/**
	 * NCAR CGD Linux Cluster (lahey), 8 pes/node, batch system is PBS
	 */
	edinburgh_lahey,

	/**
	 * NCAR CGD Linux Cluster (pgi), 8 pes/node, batch system is PBS
	 */
	edinburgh_pgi,

	/**
	 * NCAR CGD Linux Cluster (intel), 8 pes/node, batch system is PBS
	 */
	edinburgh_intel,

	/**
	 * Purdue TG-Steele (Test Profile), RHEL5, 8/node, PBS
	 */
	steele,

	/**
	 * NERSC XT4, os is CNL, 4 pes/node, batch system is PBS
	 */
	franklin,

	/**
	 * UCB Linux Cluster, os is Linux (ia64), batch system is PBS
	 */
	hadley,

	/**
	 * ANL IBM BG/P, os is BGP, 4 pes/node, batch system is cobalt
	 */
	intrepid,

	/**
	 * ORNL XT4, os is CNL, 4 pes/node, batch system is PBS
	 */
	jaguar,

	/**
	 * ORNL XT5, os is CNL, 12 pes/node, batch system is PBS
	 */
	jaguarpf,

	/**
	 * NICS/UT/teragrid XT5, os is CNL, 12 pes/node
	 */
	kraken,

	/**
	 * ARSC Sun Cluster, os is Linux (pgi), batch system is PBS
	 */
	midnight,

	/**
	 * LLNL Linux Cluster, Linux (pgi), 8 pes/node, batch system is Moab
	 */
	prototype_atlas,

	/**
	 * NASA Ames Linux Cluster, Linux (ia64), 2 pes/node, batch system is PBS
	 */
	prototype_columbia,

	/**
	 * NCAR IBM BG/L, os is BGL, 8 pes/node, batch system is cobalt
	 */
	prototype_frost,

	/**
	 * SUNY IBM BG/L, os is BGL, 8 pes/node, batch system is cobalt
	 */
	prototype_nyblue,

	/**
	 * TACC Linux Cluster, Linux (pgi), 1 pes/node, batch system is SGE
	 */
	prototype_ranger,

	/**
	 * NAS (NASA) IBM p5+, os is AIX, 2 pes/node, batch system is PBS
	 */
	prototype_schirra,

	/**
	 * LLNL IBM BG/L, os is BGL, 2 pes/node, batch system is Moab
	 */
	prototype_ubgl,

	/**
	 * generic ibm power system, os is AIX, batch system is LoadLeveler,
	 * user-defined
	 */
	generic_ibm,

	/**
	 * generic CRAY XT, os is CNL, batch system is PBS, user-defined
	 */
	generic_xt,

	/**
	 * generic linux (pgi), os is Linux, batch system is PBS, user-defined
	 */
	generic_linux_pgi,

	/**
	 * generic linux (lahey), os is Linux, batch system is PBS, user-defined
	 */
	generic_linux_lahey,

	/**
	 * generic linux (intel), os is Linux, batch system is PBS, user-defined
	 */
	generic_linux_intel,

	/**
	 * generic linux (pathscale), os is Linux, batch system is PBS, user-defined
	 */
	generic_linux_pathscale;

	/**
	 * This method replaces any '-' with '_' in input string, and returns a
	 * Machine enum type object if name matches.
	 * 
	 * @param name
	 *            input string
	 * @return Machine enum type object
	 * @throws IllegalArgumentException
	 */
	public static Machine fromString(String name)
			throws IllegalArgumentException {
		String uname = name.replaceAll("-", "_").toLowerCase();
		for (Machine m : Machine.values()) {
			if (m.name().equals(uname))
				return m;
		}
		throw new IllegalArgumentException("Can not match '" + name
				+ "' to enum Machine");
	}
}